package com.twu.biblioteca;

import java.util.ArrayList;
import com.twu.biblioteca.*;

public class AllMovies {


    ArrayList<Movie> movies = new ArrayList<Movie>();
    StringBuilder sb = new StringBuilder();



    public void addMovies(Movie obj)
    {
        movies.add(obj);

//        for(Movie m:movies)
//            System.out.println(m.movieName+"\t"+m.directorName);

    }

    public String displayMovieDetails(String mviName){
        sb.setLength(0);
        Movie mvi=null;
        for(Movie movie: this.movies){

            if( movie.movieName.compareTo(mviName) == 0 ){
                mvi=movie;
                break;
            }
        }

        if(mvi!=null ) {
            sb.append(mvi.movieName+"\t");
            sb.append(mvi.directorName+"\t");
            sb.append(mvi.releaseYear+"\t");
            sb.append(mvi.movieRating+"\n");

        }
        else
            sb.append("Sorry movie details not available in the Library");
        return sb.toString();

    }

}

